<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>开启或禁用（Mysql）内部（错误）报告函数</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysqli-param-count.html">mysqli_param_count</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysqli-rpl-parse-enabled.html">mysqli_rpl_parse_enabled</a></div>
 <div class="up"><a href="ref.mysqli.html">别名和过时的Mysqli 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.mysqli-report" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqli_report</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">mysqli_report</span> &mdash; <span class="dc-title">开启或禁用（Mysql）内部（错误）报告函数</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.mysqli-report-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>mysqli_report</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>
   )</div>

  <p class="para rdfs-comment">
  <span class="function"><strong>mysqli_report()</strong></span>在开发和测试阶段对于你的查询和代码测试的提升方面是一个非常有用的函数。
  它依赖flags参数报告从mysqli函数调用或没有使用索引（或使用了坏的索引）的查询引发的错误。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysqli-report-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">flags</code></em></dt>

     <dd>

      <p class="para">
       <table class="doctable table">
        <caption><strong>支持的flags</strong></caption>
        
         <thead>
          <tr>
           <th>名称</th>
           <th>描述</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><strong><code>MYSQLI_REPORT_OFF</code></strong></td>
           <td>关闭错误报告</td>
          </tr>

          <tr>
           <td><strong><code>MYSQLI_REPORT_ERROR</code></strong></td>
           <td>报告mysqli函数调用中的错误</td>
          </tr>

          <tr>
           <td><strong><code>MYSQLI_REPORT_STRICT</code></strong></td>
           <td>
            以抛出异常<a href="class.mysqli-sql-exception.html" class="classname">mysqli_sql_exception</a>的方式替换警告错误。
           </td>
          </tr>

          <tr>
           <td><strong><code>MYSQLI_REPORT_INDEX</code></strong></td>
           <td>如果一个查询没有索引或使用了错误的索引则报告错误</td>
          </tr>

          <tr>
           <td><strong><code>MYSQLI_REPORT_ALL</code></strong></td>
           <td>设置所有选项（报告所有）</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysqli-report-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.mysqli-report-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.2.15 &amp; 5.3.4</td>
       <td>
        修改了报告模式，现在是每个请求，而不是每个进程。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mysqli-report-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1723">
    <div class="example-contents"><p>面向对象风格</p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;激活错误报告&nbsp;*/<br /></span><span style="color: #0000BB">mysqli_report</span><span style="color: #007700">(</span><span style="color: #0000BB">MYSQLI_REPORT_ALL</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$mysqli&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"world"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;检查连接&nbsp;*/<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">mysqli_connect_errno</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Connect&nbsp;failed:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">mysqli_connect_error</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;exit();<br />}<br /><br /></span><span style="color: #FF8000">/*&nbsp;这个查询会报告一个错误&nbsp;*/<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;Name&nbsp;FROM&nbsp;Nonexistingtable&nbsp;WHERE&nbsp;population&nbsp;&gt;&nbsp;50000"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;这个查询会报告一个坏的索引&nbsp;*/<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;Name&nbsp;FROM&nbsp;City&nbsp;WHERE&nbsp;population&nbsp;&gt;&nbsp;50000"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysqli-report-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="class.mysqli-driver.html#mysqli-driver.props.report-mode" class="link">MySQLi_Driver::$report_mode</a></li>
    <li class="member"><span class="function"><a href="mysqli.debug.html" class="function" rel="rdfs-seeAlso">mysqli_debug()</a> - Performs debugging operations</span></li>
    <li class="member"><span class="function"><a href="mysqli.dump-debug-info.html" class="function" rel="rdfs-seeAlso">mysqli_dump_debug_info()</a> - 将调试信息输出到日志</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysqli-param-count.html">mysqli_param_count</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysqli-rpl-parse-enabled.html">mysqli_rpl_parse_enabled</a></div>
 <div class="up"><a href="ref.mysqli.html">别名和过时的Mysqli 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
